library(tidyverse)
myurl <- "https://raw.githubusercontent.com/reisanar/datasets/master/worldcup.csv"
mydata <- read_csv(myurl)
Information regarding players that participated in the 2010 World Cup.
glimpse(mydata)
Observations: 595
Variables: 8
$ Player <chr> "Abdoun", "Abe", "Abidal", "Abou Diaby", "Aboubakar",...
$ Team <chr> "Algeria", "Japan", "France", "France", "Cameroon", "...
$ Position <chr> "Midfielder", "Midfielder", "Defender", "Midfielder",...
$ Time <int> 16, 351, 180, 270, 46, 72, 138, 33, 21, 103, 270, 55,...
$ Shots <int> 0, 0, 0, 1, 2, 0, 0, 0, 5, 0, 2, 0, 2, 1, 1, 1, 5, 9,...
$ Passes <int> 6, 101, 91, 111, 16, 15, 51, 9, 22, 38, 120, 31, 57, ...
$ Tackles <int> 0, 14, 6, 5, 0, 0, 2, 0, 0, 1, 10, 2, 2, 11, 13, 7, 3...
$ Saves <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
library(ggplot2)
library(tidyverse)
mydata
library(plotly)
player_passes <- ggplot(data = mydata, aes(x= Time,
y=Passes, color = Position)) +
geom_point()
ggplotly(player_passes)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
The more time a player spends on the field, the more passes they are going to make.
mydata %>%
filter(Passes > 400)
The majority of the players with the most passes come from Spain’s soccer team which is actually the team that won the World cup for that year.
player_passes2 <- mydata %>%
ggplot(aes(x= Time, y=Passes,
color = Position, size= Shots,
alpha= Tackles)) +
geom_point()
ggplotly(player_passes2)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Which position tends to make more passes?
plot1 <- ggplot(mydata, aes(Time, Passes)) + geom_point(aes(color = Position)) +
scale_x_continuous("Time")+
scale_y_continuous("Passes")+
theme_bw() + labs(title="Passes Over Time by Position") + facet_wrap( ~ Position)
ggplotly(plot1)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
The midfielder position tends to make more passes.The goalkeeper hardly mkes any due to the fact that the only passes they make is when the ball reaches the goalie area.The defenders also make a lot of passes.
Which Soccer Team made the most passes in the Worldcup?
plot2 <- ggplot(mydata) +
geom_boxplot(aes(Team, Passes, fill= Team)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggplotly(plot2)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Which team had players that spent the least amount of time on the field?
plot4 <- ggplot(mydata) +
geom_boxplot(aes(Team, Time, fill = Team)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1 ))
ggplotly(plot4)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Honduras’ players spent the least amount of time on the field.
The teams that spent the most time on the field ,Spain and Netherlands made it to the final.
Below, we can count the amount of players that each team brought to the Worldcup.
plot5 <- mydata %>%
ggplot() +
geom_histogram(aes(x= Team, fill = Position), stat = "count") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Ignoring unknown parameters: binwidth, bins, pad
ggplotly(plot5)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
LS0tDQp0aXRsZTogIkEgRGF0YSBTY2llbmNlIFByb2plY3QiIA0KYXV0aG9yOiBFbGlhbmEgRXNwaW5vc2ENCm91dHB1dDogaHRtbF9ub3RlYm9vaw0KLS0tDQoNCg0KYGBge3IsIG1lc3NhZ2U9RkFMU0UsIHdhcm5pbmc9RkFMU0V9DQpsaWJyYXJ5KHRpZHl2ZXJzZSkNCm15dXJsICA8LSAiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3JlaXNhbmFyL2RhdGFzZXRzL21hc3Rlci93b3JsZGN1cC5jc3YiDQpteWRhdGEgPC0gcmVhZF9jc3YobXl1cmwpDQpgYGANCg0KIyMgSW5mb3JtYXRpb24gcmVn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